<?php $h=array();?>
<table style="width: 100%;">
    <thead>
        <tr>
            <th></th>
            <?php foreach ($structure["scale_header"] as $header_matriz): ?>
                <th><?php echo $header_matriz;$h[]=$header_matriz;; ?></th>
            <?php endforeach; ?>
        </tr>
    </thead>
    <tbody>
            <?php foreach ($structure["scale_text"] as $k => $header_text): ?>
            <tr>
                <td><?php echo $header_text ?></td>
                    <?php foreach ($h as $value): ?>
                    <td>
                        <input type="radio" name="q[<?php echo "sub][" . $q . "][" . $k ?>]" value="<?php echo $value; ?>"/>
                    </td>
                    <?php endforeach; ?>
            </tr>
            <?php endforeach; ?>
    </tbody>
</table>